<template>
  <div class="comment-reply">
    <van-nav-bar :title="`${comment.reply_count}条回复`">
      <template #left>
        <van-icon name="cross" @click="$emit('close')"></van-icon>
      </template>
    </van-nav-bar>
    <!-- 当前评论 -->
    <comment-item :comment="comment"></comment-item>
    <van-cell title="全部评论"></van-cell>
    <!-- 评论列表 -->
    <comment-list :source="comment.com_id" :type="'c'" :commemtlist="commemtList"></comment-list>
    <!-- 底部评论 -->
    <div class="article-bottom">
      <van-button
        class="comment-btn"
        type="default"
        round
        size="small"
        @click="isPostShow=true"
        block
      >写评论</van-button>
    </div>
    <!-- 评论 -->
    <van-popup v-model="isPostShow" position="bottom">
      <post-comment
        :target="comment.com_id"
        :articleId="articleId"
        @post-success="postSuccess"
      ></post-comment>
    </van-popup>
  </div>
</template>

<script>
import CommentItem from './CommentItem'
import CommentList from './CommentList'
import PostComment from './PostComment'
export default {
  name: 'CommentReply',
  props: {
    comment: {
      type: Object,
      required: true
    },
    articleId: {
      type: [Number, String, Object],
      required: true
    }
  },
  components: {
    CommentItem,
    CommentList,
    PostComment
  },
  data () {
    return {
      isPostShow: false,
      commemtList: []// 评论回复列表
    }
  },
  methods: {
    postSuccess (comment) {
      this.commemtlist.unshift(comment)
      this.comment.reply_count++
      this.isPostShow = false
    }
  }
}
</script>
<style lang="less" scoped>
  .article-bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-sizing: border-box;
  height: 44px;
  border-top: 1px solid #d8d8d8;
  background-color: #fff;
  .comment-btn {
    width: 141px;
    height: 23px;
    border: 1px solid #eeeeee;
    font-size: 15px;
    line-height: 23px;
    color: #a7a7a7;
  }
}
</style>
